<%@ taglib prefix="tags" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>批次线管理</title>
	<meta name="decorator" content="default"/>
</head>
<body>
<div class="main-content">
    <tags:breadcrumb menuId="批次线管理" />
    <div class="page-content">
    <div class="search-block" style="display:none;">
        <form:form id="searchForm" modelAttribute="batchLine" action="${ctx}/score/batchLine/" method="post" class="form-horizontal">
        <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
        <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
            <div class="form-group" style="margin-bottom: 0px;">
                <div class="col-sm-2">
                        <form:select path="provice" class="col-sm-10">
                            <form:option value="" label="-选择省份-"/>
                            <form:options items="${provinceList}" itemLabel="name" itemValue="code" htmlEscape="false"/>
                        </form:select>
                </div>
                <div class="col-sm-2">
                        <form:select path="type" class="col-sm-10">
                            <form:option value="" label="--选择科类"/>
                            <form:options items="${fns:getDictList('kemu_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                        </form:select>
                </div>
                <div class="col-sm-2">
                        <form:select path="year" class="col-sm-10">
                            <form:option value="" label="-选择年份-"/>
                            <form:options items="${fns:getDictList('close_year')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                        </form:select>
                </div>
                <div class="col-sm-2">
                        <form:select path="batchLevel" class="col-sm-10">
                            <form:option value="" label="-批次类别-"/>
                            <form:options items="${fns:getDictList('batch_level')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                        </form:select>
                </div>
                <div class="col-sm-4">
                    <div style="float: right;margin-right: 10px;">
                        <input id="btnSubmit" class="btn btn-primary btn-sm" type="submit" value="查询"/>&nbsp;&nbsp;
                        <input id="btnExport" class="btn btn-inversn btn-sm" type="button" value="导出"/>&nbsp;&nbsp;
                        <input id="btnImport" class="btn btn-warning btn-sm" type="button" value="导入"/>
                    </div>

                </div>
            </div>
    </form:form>
    </div>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>省份编码</th>
				<th>科类（文理）</th>
				<th>年份</th>
				<th>批次类别</th>
				<th>批次线分数</th>
				<th>修改时间</th>
				<shiro:hasPermission name="score:batchLine:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="batchLine">
			<tr>
				<td>
					<a href="${ctx}/score/batchLine/form?id=${batchLine.id}">${batchLine.provinceName}</a>
				</td>
				<td>
					${fns:getDictLabel(batchLine.type, 'kemu_type', '')}
				</td>
				<td>
					${fns:getDictLabel(batchLine.year, 'close_year', '')}
				</td>
				<td>
					${fns:getDictLabel(batchLine.batchLevel, 'batch_level', '')}
				</td>
				<td>
					${batchLine.batchScore}
				</td>
				<td>
					<fmt:formatDate value="${batchLine.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<shiro:hasPermission name="score:batchLine:edit"><td>
    				<a href="${ctx}/score/batchLine/form?id=${batchLine.id}" class="btn btn-info btn-mini">修改</a>
					<a href="javascript:;" class="btn btn-danger btn-mini" onclick="deleteMsg('确认要删除该批次线吗？','${ctx}/score/batchLine/delete?id=${batchLine.id}', this);">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">一分段数据导入</h4>
            </div>
            <div class="modal-body">
                <form id="importForm" action="${ctx}/score/batchLine/import" enctype="multipart/form-data"  method="post" class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 no-padding-right control-label">模板名称:</label>
                        <div class="col-sm-8">
                            <input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>
                            <span class="important">*</span>
                        </div>
                        <div col-sm-2>
                            <a href="${ctx}/score/batchLine/import/template">下载模板</a>
                        </div>
                    </div><hr>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="btnSureImport">确定</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
	$(document).ready(function() {
        //显示高级查询
        $(".search-block").show();
        $(".search_link").click(function(){
            if($(".search-block").is(":visible")){
                $(".search-block").hide();
                $(".search_link").text("高级查询");
            }else{
                $(".search-block").show();
                $(".search_link").text("隐藏查询");
            }
        });

        //导出
        $("#btnExport").click(function(){
            layer.confirm("确认要导出批次线数据吗？",function(index){
                layer.close(index);
                $("#searchForm").attr("action","${ctx}/score/batchLine/export");
                $("#searchForm").submit();
            });
        });

        //导入
        $("#btnImport").click(function(){
            $("#myModal").modal({
                backdrop:"static"
            });
        });

        //确定导入
        $("#btnSureImport").click(function(){
            $("#importForm").submit();
        });
	});

    function deleteMsg(msg,href,tr){
        layer.confirm(msg,{icon:5,title:"温馨提示"},function(index){
            loading();
            layer.close(index);
            $.post(href,function(data){
                if(data.success){
                    showNote("success", function () {
                        $(tr).parent().parent().remove();
                    }, data.msg, "center");
                }else {
                    showNote("error", function () {
                        return false;
                    }, data.msg);
                }
            });
        });
    }

	function page(n,s){
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}
</script>
</body>
</html>